<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>全部图书信息</title>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <script th:src="@{/js/jquery-3.2.1.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
    <style>
        body {
            background-color: rgb(240, 242, 245);
        }
    </style>
</head>
<body>

<div th:replace="components/adminPublicComponents::topbar"></div>


<div style="padding: 70px 550px 10px">
    <form method="post" th:action="@{/queryBook}" class="form-inline" id="searchform">
        <div class="input-group">
            <input type="text" placeholder="输入图书名" class="form-control" id="search" name="searchWord">
            <span class="input-group-btn">
                <input type="submit" value="搜索" class="btn btn-default">
            </span>
        </div>
    </form>
    <script>
        function mySubmit(flag) {
            return flag;
        }

        $("#searchform").submit(function () {
            var val = $("#search").val();
            if (val === '') {
                alert("请输入关键字");
                return mySubmit(false);
            }
        })
    </script>
</div>
<div th:replace="components/adminPublicComponents::message"></div>

<div class="panel panel-default" style="width: 90%;margin-left: 5%">
    <div class="panel-heading" style="background-color: #fff">
        <h3 class="panel-title">
            全部图书
        </h3>
    </div>
    <div class="panel-body">
        <table class="table table-hover">
            <thead>
            <tr>
                <th>书名</th>
                <th>作者</th>
                <th>出版社</th>
                <th>ISBN</th>
                <th>价格</th>
                <th>借还</th>
                <th>详情</th>
                <th>编辑</th>
                <th>删除</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="book:${bookInfoList}">
                <td th:text="${book.getName()}"></td>
                <td th:text="${book.getAuthor()}"></td>
                <td th:text="${book.getPublish()}"></td>
                <td th:text="${book.getIsbn()}"></td>
                <td th:text="${book.getPrice()}"></td>
                <td th:if="${book.getState()==1}">
                    <a th:href="@{/lendbook/borrowBook(bookId=${book.getBookId()})}">
                        <button type="button" class="btn btn-primary btn-xs">借阅</button>
                    </a>
                </td>
                <td th:if="${book.getState()==0}">
                    <a th:href="@{/lendbook/alsoBook(bookId=${book.getBookId()})}">
                        <button type="button" class="btn btn-primary btn-xs">归还</button>
                    </a>
                </td>
                <td>
                    <a th:href="@{/bookDetail(bookId=${book.getBookId()})}">
                        <button type="button" class="btn btn-success btn-xs">详情</button>
                    </a>
                </td>
                <td>
                    <a th:href="@{/bookEdit(bookId=${book.getBookId()})}">
                        <button type="button" class="btn btn-info btn-xs">编辑</button>
                    </a>
                </td>
                <td>
                    <a th:href="@{/bookDelete(bookId=${book.getBookId()})}">
                        <button type="button" class="btn btn-danger btn-xs">删除</button>
                    </a>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

</body>
</html>
